/**
 * 
 */
package com.mindtree.vi.presentation.servlet;

import com.mindtree.vi.business.javaservice.JavaService;
import com.mindtree.vi.business.javaservice.ServiceCommandType;
import com.mindtree.vi.business.javaservice.ServiceResponse;
import com.mindtree.vi.business.javaservice.SimpleJavaCompilationService;
import com.mindtree.vi.presentation.annotation.ReferencedBy;
import com.mindtree.vi.xml.XmlCompileRequest;
import com.mindtree.vi.xml.XmlCompileResponse;
import com.mindtree.vi.xml.XmlResponse;
import com.mindtree.vi.xml.config.XmlConfigUtil;

/**
 * @author venkatesh
 * 
 */
public class CompileCodeServlet extends
		BaseHttpServlet<XmlCompileRequest, XmlCompileResponse> {

	private static final long serialVersionUID = 6984790936657137030L;

	@ReferencedBy("compilationService")
	private JavaService compilationService;

	@Override
	public void process() {
		XmlCompileRequest xmlRequest = getRequest();
		ServiceResponse xmlResponse = compilationService.invokeService(
				ServiceCommandType.COMPILE, extractClassName(xmlRequest
						.getSourceCode()));
		XmlCompileResponse compileResponse = new XmlCompileResponse();
		compileResponse.setStatusCode(xmlResponse.getCode());
		compileResponse.setMessage(xmlResponse.getMessage());
		setResponse(compileResponse);
	}

}
